package com.ywl.task.controller;

import com.ywl.task.pojo.Task;
import com.ywl.task.service.TaskService;
import com.ywl.task.util.pojo.QdResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 严伟伦
 * @Company 无
 * @Description
 * @Date: 2024/9/10 11:24
 */
@RestController
@RequestMapping("/task")
@CrossOrigin
public class TaskController {
    @Autowired
    private TaskService taskService;

    @GetMapping("/list")
    public QdResult selectList(Task task,String projectId,Long parentId){
        System.out.println("22222222222222222222222222222222222222222222222222222222222"+task);
        return taskService.selectList(task,projectId,parentId);
    }
    @GetMapping("/listByUserId")
    public QdResult selectListByUserId(Long userId){

        return taskService.selectListByUserId(userId);
    }




    @PostMapping("/add")
    public QdResult addTask(@RequestBody Task task){
        return taskService.addTask(task);
    }

    @PutMapping("/updateParent")
    public QdResult updateTaskParentById(@RequestParam("taskId") Long taskId){
        System.out.println("111111111111111111111111" + taskId);
        return taskService.updateTaskParentById(taskId);
    }


    @PutMapping("/updateTask")
    public QdResult updateTask(@RequestBody Task task){
        return taskService.updateTask(task);
    }

    @PutMapping("/deleteTask")
    public QdResult updateTaskStatusById(@RequestParam("taskId") Long taskId){
        return taskService.updateTaskStatusById(taskId);
    }

    @PutMapping("deletes")
    public QdResult updateTaskStatusByIds(@RequestBody Long [] taskIds){
        System.out.println("111111111111111111111111111" + taskIds);
        return taskService.updateTaskStatusByIds(taskIds);
    }
}
